package com.lmt.controller;

import com.lmt.entity.User;
import com.lmt.feign.ProviderFeignClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户Controller
 * Date 2018/06/28
 *
 * @author MT-Lin
 */
@SuppressWarnings("ALL")
@RestController
public class UserController {

    private final ProviderFeignClient providerFeignClient;

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    public UserController(ProviderFeignClient providerFeignClient) {
        this.providerFeignClient = providerFeignClient;
    }

    @GetMapping("/findUserById")
    public User findUserById(@RequestParam(name = "id") String id){
        logger.warn("consumer-feign-hystrix-fallback->findUserById:id={}", id);
        return providerFeignClient.findUserById(id);
    }
}
